//
//  ReportQueryCell.swift
//  ANOA
//
//  Created by zwb on 2016/11/14.
//  Copyright © 2025 aowang. All rights reserved.
//

import UIKit

class ReportInputCell: UITableViewCell {

    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var detailLabel: UITextField!
    var selectAction: ((String) -> Void)?

    var reportParameter: ReportDetail? {
        didSet {

           
            var titleShow = reportParameter?.titleCs
            if containsChineseCharacter(reportParameter!.titleNm.unwrap) {
                titleShow = reportParameter?.titleNm
            }
            titleLabel.text = titleShow
            
            detailLabel.text = reportParameter?.defaultVal
            if let selectAction = self.selectAction {
                let postChar = reportParameter?.sPostChar ?? ""
                let sPrefixChar = reportParameter?.sPrefixChar ?? ""
                let defaultVal = reportParameter?.defaultVal ?? ""
                selectAction(sPrefixChar + defaultVal + postChar)

            }
        }
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        detailLabel.textAlignment = .right
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    @IBAction func saveTextfield(_ sender: UITextField) {
        if let selectAction = self.selectAction {
            let postChar = reportParameter?.sPostChar ?? ""
            let sPrefixChar = reportParameter?.sPrefixChar ?? ""
            selectAction(sPrefixChar + sender.text! + postChar)

        }
    }
}
